﻿using CPPEI.ETL.DataServiceInterface;
using CPPEI.WebApi;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using ENT = CPPEI.ETL.Domain.Entities;
using MOD = CPPEI.ETL.Domain.Models;
using SER = CPPEI.ETL.Domain.Services;

namespace CPPEI.ETL.WebApi
{
    /// <summary>
    /// 手动完成任务
    /// </summary>
    [CPPEI.WebApi.PostAction("ETL", "ManualFinishTask", "1.0")]
    public class ManualFinishTaskAction : BaseAction<ManualFinishTaskParams, ManualFinishTaskResult>
    {
        protected override ActionResult<ManualFinishTaskResult> OnExecute(ActionContext context, 
            SysParameters sysParameters,
            ManualFinishTaskParams opParams)
        {
            Logger.DebugToTag(Library.LogTAG, string.Format("ManualFinishTaskAction,TaskId:{0}", opParams.TaskId));

            SER.TaskService service = new SER.TaskService();

            ServiceResult serResult = service.ManualFinish(context.UserId, opParams.TaskId);

            if (serResult.IsSuccess)
            {
                ManualFinishTaskResult result = new ManualFinishTaskResult();
                return new ActionResult<ManualFinishTaskResult>(result);
            }
            else
            {
                return new ActionResult<ManualFinishTaskResult>(serResult.IsSuccess, serResult.ErrorCode, serResult.Message, null);
            }
        }
    }

    public class ManualFinishTaskParams
    {
        [Parameter]
        public Guid TaskId { get; set; }
    }

    public class ManualFinishTaskResult
    {
    }
}
